//
//  LOLSkillDetailViewController.m
//  LOLXXbox
//
//  Created by dllo on 16/2/27.
//  Copyright © 2016年 Grasstrio. All rights reserved.
//

#import "LOLSkillDetailViewController.h"
#import "LOLFirstSkillTableViewCell.h"
#import "LOLSecondSkilltableViewCell.h"
#import "LOLThirdSkillTableViewCell.h"
#import "LOLForthSkillTableViewCell.h"
#import "LSZNetWorkTools.h"
#import "LOLSkillsModel.h"

@interface LOLSkillDetailViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong) UITableView *tableView;


@end

@implementation LOLSkillDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self createTableView];
 
}

- (void)createTableView{
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, - 32, self.view.frame.size.width, self.view.frame.size.height - 64) style:UITableViewStyleGrouped];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    [self.tableView registerClass:[LOLFirstSkillTableViewCell class] forCellReuseIdentifier:@"cell"];
    [self.tableView registerClass:[LOLSecondSkilltableViewCell class] forCellReuseIdentifier:@"cell2"];
    [self.tableView registerClass:[LOLThirdSkillTableViewCell class] forCellReuseIdentifier:@"cell3"];
    [self.tableView registerClass:[LOLForthSkillTableViewCell class] forCellReuseIdentifier:@"cell4"];
    [self.view addSubview:_tableView];
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        LOLFirstSkillTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
        cell.skillModel = self.skillModel;
        return cell;
    }else if (indexPath.section == 1){
        LOLSecondSkilltableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:@"cell2"];
        cell.skillModel = self.skillModel;

        return cell;
    }else if (indexPath.section == 2){
        LOLThirdSkillTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell3"];

        return cell;
    }else{
        LOLForthSkillTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell4"];
        cell.skillModel = self.skillModel;
        return cell;
    }
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 4;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        return nil;
    }else if (section == 1){
        return @"描述";
    }else if (section == 2){
        return @"天赋强化";
    }else{
        return @"提示";
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 32;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return CGFLOAT_MIN;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return 100;
    }else if (indexPath.section == 1){
        LOLSecondSkilltableViewCell *cell = (LOLSecondSkilltableViewCell *)[self tableView:tableView cellForRowAtIndexPath:indexPath];
        [cell layoutSubviews];
        return [cell getHeight];
    }else if (indexPath.section == 2){
        return 20;
    }else{
        LOLForthSkillTableViewCell *cell = (LOLForthSkillTableViewCell *)[self tableView:tableView cellForRowAtIndexPath:indexPath];
        [cell layoutSubviews];
        return [cell getHeight];
    }
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
